/**
 * Copyright (C)  2011  chen wei hua.
 * Permission is granted to copy, distribute and/or modify this document
 * under the terms of the GNU Free Documentation License, Version 2.0
 * or any later version published by the Free Software Foundation;
 * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 * A copy of the license is included in the section entitled "GNU Free Documentation License".
 */
package com.javaeye.delivery.dto;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import com.javaeye.common.dto.DTO;
import com.javaeye.common.util.DateUtils;

public class CustomerOrder implements DTO {
	
	public static final int ORDER_STATES_CLOSED = 0;
	
	public static final int ORDER_STATES_CREATED = 1;
	
	public static final int ORDER_STATES_PLAN = 2;
	
	public static final int ORDER_STATES_BUSINESS = 3;
	
	public static final int ORDER_STATES_PREPARE_OUT = 4;
	
	public static final int ORDER_STATES_CHECKED = 5;
	
	public static final int ORDER_STATES_CREATED_DELIVERY_ORDER = 6;
	
	public static final int ORDER_STATES_WAIT_CLOSE = 7;
	
	public static final int ORDER_STATES_END = 20;
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 6894920169941893269L;

	private String id;
	
	private Date createDate;
	
	private String customName;
	
	private int customId;
	
	private String contractNo;
	
	private Date expectOutDate;
	
	private Date outDate;
	
	private String batchNumber;
	
	private int status;
	
	private String statusMessage;
	
	private String logisticsType;
	
	private String arriveDate;
	
	private String purchaseOrderId;
	
	private Date updateDate;

	private Set<OrderDetail> orderDetails = new HashSet<OrderDetail>();
	
	private long reasons;
	
	private String closeReason;
	
	private Integer oldStatus;
	
	/**
	 * 取得最后一次更新到现在的时间
	 * @return
	 */
	public String getWaitTime() {
		return DateUtils.getDateOffsetString(updateDate, DateUtils.now());
	}
	
	public void addDetail(OrderDetail detail) {
		detail.setOrder(this);
		orderDetails.add(detail);
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getCustomName() {
		return customName;
	}

	public void setCustomName(String customName) {
		this.customName = customName;
	}

	public int getCustomId() {
		return customId;
	}

	public void setCustomId(int customId) {
		this.customId = customId;
	}

	public String getContractNo() {
		return contractNo;
	}

	public void setContractNo(String contractNo) {
		this.contractNo = contractNo;
	}

	public Date getExpectOutDate() {
		return expectOutDate;
	}

	public void setExpectOutDate(Date expectOutDate) {
		this.expectOutDate = expectOutDate;
	}

	public Set<OrderDetail> getOrderDetails() {
		return orderDetails;
	}

	public void setOrderDetails(Set<OrderDetail> orderDetails) {
		this.orderDetails = orderDetails;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getId() {
		return id;
	}

	public void setBatchNumber(String batchNumber) {
		this.batchNumber = batchNumber;
	}

	public String getBatchNumber() {
		return batchNumber;
	}

	public void setOutDate(Date outDate) {
		this.outDate = outDate;
	}

	public Date getOutDate() {
		return outDate;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getStatus() {
		return status;
	}

	public String getStatusMessage() {
		return statusMessage;
	}

	public void setStatusMessage(String statusMessage) {
		this.statusMessage = statusMessage;
	}

	public void setArriveDate(String arriveDate) {
		this.arriveDate = arriveDate;
	}

	public String getArriveDate() {
		return arriveDate;
	}

	public void setLogisticsType(String logisticsType) {
		this.logisticsType = logisticsType;
	}

	public String getLogisticsType() {
		return logisticsType;
	}

	public void setPurchaseOrderId(String purchaseOrderId) {
		this.purchaseOrderId = purchaseOrderId;
	}

	public String getPurchaseOrderId() {
		return purchaseOrderId;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public long getReasons() {
		return reasons;
	}

	public void setReasons(long reasons) {
		this.reasons = reasons;
	}

	/**
	 * @param closeReason the closeReason to set
	 */
	public void setCloseReason(String closeReason) {
		this.closeReason = closeReason;
	}

	/**
	 * @return the closeReason
	 */
	public String getCloseReason() {
		return closeReason;
	}

	/**
	 * @param oldStatus the oldStatus to set
	 */
	public void setOldStatus(Integer oldStatus) {
		this.oldStatus = oldStatus;
	}

	/**
	 * @return the oldStatus
	 */
	public Integer getOldStatus() {
		return oldStatus;
	}
	
}
